// Enkelt bekräftelse-plugin
(function($) {
	// confirm options and defaults
	$.confirm = {
		defaults: {
			confirmText: '�tg�rden kan ej �ngras, v�nligen bekr�fta:'
		}
	};
	
    $.fn.confirm = function(options) {
    	
    	var options = $.extend({}, $.confirm.defaults, options);
    	
    	return this.each(function() {
    		$(this).click(function(e) {
		        if (confirm(options.confirmText)) return true;
		        return false;
    		});
    	});
    };
})(jQuery);    

// Gör en hel yta (div, li, table, td etc) klickbar, genom att hitta första bästa länk (child)
(function($) {

	// clickMe options and defaults
	$.clickMe = {
		defaults: {
			ignoreClass: 'ignoreClick'
		}
	};
	
    $.fn.clickMe = function(options) {
    
    	var options = $.extend({}, $.clickMe.defaults, options);
    
    	// Creates a new instance of clickMe
    	return this.each(function() {
    		var top = $(this);
    		top.click(function(e) {
    			clickMe_onClick(top, $(this), e);
    		});
    	});
    	
    	// Occurs when user clicks the container or any of its child elements
		function clickMe_onClick(container, trigger, e) {
			// Ignore clickMe if clicked item has the ignore-class
			if($(e.target).hasClass(options.ignoreClass)) return true;
			
			// Prevent click, find first anchor and redirect!
			e.preventDefault();
			var target = container.find('a[href]:first').attr('href');
			if(target != undefined)
				window.location.href = target;
		}
    	
    };
    
})(jQuery);